package com.cloudcross.ssp.common.utils;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 创建人：wuqiang.du 创建时间：2016.05.17
 */
public class String2MapUtils {
    /**
     * 把String转换成Map
     * 
     * @param str 要处理的字符串，以“，”分隔，如ID1，ID2，ID3，...
     * @param key 存放处理后的数据的key值
     * @return Map{key:Set} set = [id1,id2,id3,...]
     */
    public static Map<String, Object> modifyString2Map(String str, String key) {
        Map<String, Object> condition = new HashMap<String, Object>();
        Set<Long> idSet = new HashSet<Long>();
        if (!"".equals(str) && str != null) {
            String[] ids = str.split(",");
            for (int i = 0; i < ids.length; i++) {
                idSet.add(Long.parseLong(ids[i]));
            }
            condition.put(key, idSet);
        } else {
            idSet.add(-1l);
            condition.put(key, idSet);
        }
        return condition;
    }

    public static List<Long> modifyString2List(String str, String key) {
        return null;
    }
}
